package study.DesignPattern.Singleton;

import com.sun.org.apache.bcel.internal.generic.RETURN;

public class SingleObject {
//创建一个Singleton对象
    //懒汉式是先申明 private static SingleObject instance
    private static SingleObject instance = new SingleObject();

    //让构造函数为private，这样类就不会实例化
    private SingleObject(){}

    //获取唯一可用的对象，在static后面加上synchronized(线程安全)
    public static SingleObject getInstance(){
        //懒汉式 return instance = new SingleObject();
        return instance;

    }
public void showMessage(){
    System.out.println("hello world!!!");
}
}
